package cn.itsource.pethome.base.util;

import lombok.Getter;
import lombok.ToString;

@Getter
@ToString
public class AjaxResult {
    //私有化构造方法
    private AjaxResult(){}
    private Boolean state = true;
    private String message = "操作成功";

    public static AjaxResult me(){
        return new AjaxResult();
    }

    /**
     * 成功使用
     * @return
     */
    public static AjaxResult success(){
        return me();
    }

    public static AjaxResult error(){
        return me().setMessage("操作失败").setState(false);
    }

    //链式编程
    private AjaxResult setState(Boolean state){
        this.state = state;
        return this;
    }
    private AjaxResult setMessage(String message){
        this.message = message;
        return this;
    }
}
